#include <iostream>

#include "WingCoroutine/wingcoroutine.h"

static void testHandler(Wing::WingCoroutine *co, void *param) {
  Wing::WingCoroutine::co_while(co, true, [param]() {
    std::cout << "This is an " << reinterpret_cast<char *>(param) << "!"
              << std::endl;
  });
}

int main(int argc, char *argv[]) {
  Wing::WingCoroutine co(1024 * 1024 * 1024);

  co.sendCOAPC([]() { std::cout << "[1] hello world!!!" << std::endl; });
  co.sendCOAPC([]() { std::cout << "[2] hello world!!!" << std::endl; });
  std::cin.get();

  auto id = co.createThread(testHandler, new char[]{"umbralla"});
  co.createThread(testHandler, new char[]{"apple"});
  std::cin.get();

  co.stopThread(id);
  std::cin.get();

  co.stopAllThread();
  std::cin.get();

  return 0;
}
